/*
 * Copyright 2008-2009 the original 赵永春(zyc@hasor.net).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.more.util;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 时间工具类
 * @version : 2015年6月24日
 * @author 赵永春(zyc@hasor.net)
 */
public class DateUtils {
    public static final String FORMAT_YEAR  = "yyyy";
    public static final String FORMAT_MONTH = "MM";
    public static final String FORMAT_DAYS  = "dd";
    public static final String FORMAT_YMD   = "yyyy-MM-dd";
    //
    /**获取当前时间：年*/
    public static String currentYearStr() {
        return getTimeForMormat(new Date(), FORMAT_YEAR);
    }
    /**获取当前时间：月*/
    public static String currentMonthStr() {
        return getTimeForMormat(new Date(), FORMAT_MONTH);
    }
    /**获取当前时间：日*/
    public static String currentDaysStr() {
        return getTimeForMormat(new Date(), FORMAT_DAYS);
    }
    /**获取当前时间：年-月-日*/
    public static String currentYearMonthDay() {
        return getTimeForMormat(new Date(), FORMAT_YMD);
    }
    /**按照格式获取时间格式化之后的获取当前时间：日*/
    public static String getTimeForMormat(Date date, String format) {
        if (date == null)
            return null;
        return new SimpleDateFormat(format).format(date);
    }
    /**是否是过期的时间（依照当前时间）*/
    public static boolean isOverTime(Date date) {
        if (date == null) {
            return false;
        }
        return date.getTime() <= System.currentTimeMillis();
    }
}